
//  var centerRUI="http://192.168.1.17:8080/centerweb/cloud";//登录 
//  var centerRUI1="http://192.168.1.17:8080/centerweb";//登录
toastr.options = {
    closeButton: false,
    debug: false,
    progressBar: false,
    positionClass: "toast-top-center",
    onclick: null,
    showDuration: "300",
    hideDuration: "1000",
    timeOut: "2000",
    extendedTimeOut: "1000",
    showEasing: "swing",
    hideEasing: "linear",
    showMethod: "fadeIn",
    hideMethod: "fadeOut"
};
  var valueArr = [];
$(function(){
    //初始化
    refreshCheckCode();
    var loginName = $("#loginName").val();
    var password = $("#password").val();
    var code = $("#code").val();
    //自动登录
    $("#code").bind('keyup', function () {
        if ($("#code").val().length == 4) {
            return $('#login').click();
        }
    });
    //登录验证
    $('#login').click(function() {
        $.ajax({
            type: "GET",
            url: centerRUI + "/sysUser/login?",
            data: {
                loginName: $("#loginName").val(),
                password: $("#password").val(),
                code: $("#code").val(),
                jsessionids:$.cookie('jsessionids')
            },
            dataType: "jsonp",
            crossDomain: true,
            jsonp:"callback",    
            jsonpCallback:"success_jsonp",
            success: function (data) {
            	data=data[0];
            	debugger;
                if (data.result == 'SUCCESS') {
                    //将用户信息保存在cookie中
                	$.cookie('jsessionids', data.tokin, {path: '/'});
                    /*$.cookie('userId', data.id); //用户Id
                    $.cookie('loginName', data.code); //用户名称
                    $.cookie('trueName', data.fullName); //用户名称
                    $.cookie('orgId', data.orgId); //部门编号
                    $.cookie('loginPwd', data.loginPwd); //用户密码
                    $.cookie('ip', data.ip);//用户本机ip
                    $.cookie('loginTime', new Date().getTime(), {
                        path: '/'
                    });
                    $.cookie('language', 'zh-CN', {
                        path: '/'
                    });//默认中文
*/                    getAllParams();
                } else {
                	toastr.error(data.result);
                    refreshCheckCode();
                }
            }
        });
    });
    $("#check-label").click(function(){
        if($("#check-box").hasClass('checked')){
            $("#check-box").removeClass("checked").addClass("checked-none");
        }else{
            $("#check-box").removeClass("checked-none").addClass("checked");
        }
    });
});
//刷新验证码
function refreshCheckCode() {
	var url = centerRUI1 + '/servlet/ValidateCodeServlet?jsessionids='+$.cookie('jsessionids')+'&' + Math.random();
	$('#Verify_codeImag').attr('src', url);
}
//回车键
document.onkeydown = function (e) {
    if (!e) {
        e = window.event;
    }
    // window.event
    if ((e.keyCode || e.which) == 13) {
       $('#login').click();
    }
};
$("#check-label").click(function(){
	if($("#check-box").hasClass('checked')){
		$("#check-box").removeClass("checked").addClass("checked-none");
	}else{
		$("#check-box").removeClass("checked-none").addClass("checked");
	}
});

//获取门诊界面参数设置
function getAllParams()
{
	debugger;
	$.ajax(
	{
	url : rootUrl + "/patientsearch/findSysparams1",
	data :
	{userid:$.cookie("userId")},
	async : false,
	type:"get",
	dataType:"json",
	success : function(result)
	{
		myurl += result.list[0].value;
		window.location.href = myurl+"/main.jsp"; //主页面
	},
	error:function(a,b,c)
	{
		console.log(c);
	}
	});
}
